class TranquilizatorSlowingProj extends FlameTendril;

var KFMonster StuckTo;
var	float Duration;
var int Stucks;

replication
{
	reliable if ( Role == ROLE_Authority )
		Stucks;
}

simulated function PostBeginPlay();
simulated singular function HitWall(vector HitNormal, actor Wall)
{
	Destroy();
}
simulated function Landed( vector HitNormal )
{
	Destroy();
}
simulated function Explode(vector HitLocation,vector HitNormal)
{
	Destroy();
}
simulated function ProcessTouch (Actor Other, vector HitLocation);
simulated function Destroyed();

function Timer()
{
	if (StuckTo != None)
	{
		if ( StuckTo.Health <= 0 )
			Destroy();
			
		if ( Role == ROLE_Authority )
		{
			DKMonster(StuckTo).RemoveSlowingDebuf(class'DKMonster'.default.MC_TRANQ);
		}
	}
	else
	{
		Destroy();
	}
	
	if ( --Stucks <= 0 )
	{
		Destroy();
	}
}

function SetSpeeds()
{
	local float Duration;
	local int i;
	
	Stucks = int(Duration / 0.499);

	for(i=0; i<Stucks; i++)
	{
		DKMonster(StuckTo).AddSlowingDebuf(class'DKMonster'.default.MC_TRANQ);
	}
}

simulated function Stick(actor HitActor, vector HitLocation)
{
	local name NearestBone;
	local float dist;

	StuckTo=KFMonster(HitActor);
	SetSpeeds();
	
	SetPhysics(PHYS_None);

	NearestBone = GetClosestBone(HitLocation, HitLocation, dist , 'CHR_Spine2' , 15 );
	HitActor.AttachToBone(self,NearestBone);
	
	SetTimer(0.5,true);
}

simulated function DestroyTrail()
{
	if ( Trail != none )
	{
		Trail.mRegen=False;
		Trail.SetPhysics(PHYS_None);
	}

	if ( FlameTrail != none )
	{
		FlameTrail.Kill();
		FlameTrail.SetPhysics(PHYS_None);
	}
}

defaultproperties
{
     Speed=1.000000
     MaxSpeed=1.000000
     DrawType=DT_StaticMesh
     StaticMesh=StaticMesh'KF_pickups2_Trip.Supers.MP7_Dart'
     LifeSpan=999.000000
     DrawScale=0.010000
}
